from django.shortcuts import redirect


def check_login_middleware(func):

    def wrapper(request, *args, **kwargs):
        path = request.path
        if path in ('/vote/pdf/', '/vote/excel/'):
            if 'user' not in request.session:
                return redirect('a:login')
        return func(request, *args, **kwargs)

    return wrapper
